Skip to content

Add dedicated ACP server runtime with model selection support#545

Merged
GCWing merged 3 commits intoGCWing:mainfrom
wgqqqqq:feature/acp-server-model-selection
Apr 26, 2026
Merged

Add dedicated ACP server runtime with model selection support#545
GCWing merged 3 commits intoGCWing:mainfrom
wgqqqqq:feature/acp-server-model-selection

Conversation

@wgqqqqq
Copy link
Copy Markdown
Collaborator

@wgqqqqq wgqqqqq commented Apr 26, 2026

Summary

This PR moves BitFun's ACP server integration out of the CLI-specific module into a dedicated bitfun-acp crate and expands the ACP server surface so editor clients can use BitFun more like a first-class ACP agent.

Key changes:

  • Add a dedicated src/crates/acp crate backed by the official agent-client-protocol crate.
  • Keep bitfun-cli acp as the startup host while moving ACP protocol/runtime logic behind a reusable crate boundary.
  • Add ACP prompt parsing for text, images, embedded resources, and resource links.
  • Add ACP session list/load support and session mode updates backed by the core coordinator.
  • Provision ACP-provided MCP servers as ephemeral runtime MCP configs without persisting them to disk.
  • Add ACP model selection support via both session/set_model and session/set_config_option.
  • Route leading inline <think>...</think> text chunks into ACP thought chunks so reasoning markup does not leak into normal assistant messages.

Motivation

BitFun is evolving from only exposing local product flows to also acting as an ACP-compatible agent server. The previous ACP implementation lived under the CLI app and mixed protocol handling with CLI runtime concerns. That made it harder to reuse, harder to compare against other ACP servers, and incomplete for clients such as Zed that expect session model/config options.

This PR follows the repository boundary rule: product/session behavior stays in bitfun-core, while ACP protocol adaptation lives in a dedicated adapter crate.

Implementation Notes

  • bitfun-acp depends on bitfun-core; no core crate depends on ACP.
  • EventQueue::subscribe() lets ACP listen to core events without consuming the global event stream.
  • ConversationCoordinator::update_session_agent_type and update_session_model are used as the core-facing mutation points for ACP mode/model changes.
  • ACP mcpServers are converted into ephemeral MCP server configs so they are available for the session runtime without changing saved user configuration.
  • The model selector exposes an auto option to preserve BitFun's existing mode/agent default-model behavior, plus all enabled configured models.
  • Inline think routing is intentionally scoped to ACP output boundaries and only activates for leading <think> markup, preserving literal tags in normal message text.

Validation

  • cargo check -p bitfun-acp
  • cargo test -p bitfun-acp
  • cargo build -p bitfun-cli --release

wgqqqqq added 3 commits April 26, 2026 17:05
Use the official agent-client-protocol crate from a new bitfun-acp crate and keep bitfun-cli as the startup host only.

Also move shared AgenticSystem assembly into core and fix UTF-8 cursor handling in the CLI startup workspace input.
@GCWing GCWing merged commit f91364a into GCWing:main Apr 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants